<form action="<?php echo $this->escape($this->element->getAction()) ?>"
      method="<?php echo $this->escape($this->element->getMethod()) ?>" class="form-horizontal">

	<div class="control-group">
	  <?php foreach($this->element as $element): ?>
		
			
       		<?php if($element->getName() != "submit"): ?>
       		<?php echo $this->formLabel($element->getName(),$this->translate($element->getLabel()),array('class' => 'control-label')) ?>
       		<div class="controls">
      		<?php echo $this->{$element->helper}(
                         $element->getName(),
                         $element->getValue(),
                         $element->getAttribs(),
                         (method_exists($element,'getMultiOptions')) ? $element->getMultiOptions() : ''
     		) ?>
       		<?php 	
      				$formErrors = $this->getHelper('formErrors');
      				$formErrors	->setElementStart('<div class="alert alert-error"><button class="close" data-dismiss="alert" type="button">×</button>')
      							->setElementSeparator('<br />')
      							->setElementEnd('</div>');
      		 foreach ($element->getMessages() as $msg):
      		 $verif = $msg;
      		 endforeach;
      		 if(!empty($verif)):
     		 echo $er = $this->formErrors($element->getMessages()); 
      		 endif;
      		 ///***////
      		 foreach ($element->getMessages() as $msg):
      		 $error[$i] =+ " ".$msg;
      		 $i++;
      		 endforeach;
      		 if(!empty($verif)):
      		 echo $er = $this->formErrors($element->getMessages());
      		 endif;
      		 ?>
     		 </div>
      		<?php else:?>	
      		<div class="form-actions">
      		<?php echo $this->formSubmit($element->getName(),$this->translate($element->getLabel()),array('class' => 'btn btn-primary'));?>
      		<button class="btn" type="reset" ><?php echo $this->translate('Cancel'); ?></button>
      		</div>
     		<?php endif;?>
     		<br>
	  <?php endforeach; ?>
	  </div>
		

</form>